const path = require('path')
const webpack = require('webpack')
const vueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const uglifyjsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    entry:'./src/main.js',
    output:{
        path:path.join(__dirname,'dist'),
        filename:'build.js'
        // publicPath:'dist/'
    },
    module:{
        rules:[
            {
                test:/\.vue$/,
                loader:'vue-loader'
            },
            {
                test: /\.js$/,
                loader: 'babel-loader'
            },
            {
                test: /\.css$/,
                use: [
                  'vue-style-loader',
                  'css-loader'
                ]
            }
        ]
    },
    resolve:{
        // 后缀名简写配置
        extensions:['.js','.vue','.css'],
        // vue导入指定文件
        alias:{
            'vue$':'vue/dist/vue.esm.js'  
        }
    },
    devServer:{ // 配置实时刷新
        contentBase:'/dist',
        inline:true
    },
    plugins: [
        new webpack.BannerPlugin('最终版权归 xxx---xxx--xxx 所有！'),
        new HtmlWebpackPlugin({
            template:'index.html' // html文件模版
        }),
        new vueLoaderPlugin(), 
        new uglifyjsPlugin() //js压缩插件
    ]
}